﻿var Dict = function () { };
Dict.prototype = {
    GetDictDDLByType: function ($DictType) {
        //根据类型获取简单下拉列表
        var result = "";
        $.ajax({
            type: "post",
            url: "../../../Handler/DictHandler.ashx",
            dataType: "json",
            data: { type: 5, DictType: $DictType },
            async: false,
            cache: true,
            complete: function () {
            },
            success: function (data) {

                var str = '<option value="-1">请选择</option>';
                $(data.Data).each(function (i, e) {
                    str += '<option value="' + e.DictId + '">' + e.DictName + '</option>';
                });
                result = str;
            }
        });
        return result;
    },
    GetDictRadioListByType: function ($DictType,$RadioName) {
        //获取单选列表
        var result = "";
        $.ajax({
            type: "post",
            url: "../../../Handler/DictHandler.ashx",
            dataType: "json",
            data: { type: 5, DictType: $DictType },
            async: false,
            cache: true,
            complete: function () {
            },
            success: function (data) {
                var str = '';
                $(data.Data).each(function (i, e) {
                    if (i == 0) {
                        str += '<input type="radio" class="form-horizontal radio_1 text radio_jia" name="' + $RadioName + '" value="' + e.DictId + '" checked="checked"/>' + e.DictName;
                    }
                    else {
                        str += '<input type="radio" style="margin-left: 10px" class="form-horizontal radio_1 text radio_jia" name="' + $RadioName + '" value="' + e.DictId + '" />' + e.DictName;
                    }
                    
                });
                result = str;
            }
        });
        return result;
    },
    GetDictDDLByTypePId: function ($DictType, $PId) {
        //根据类型及父级ID获取单选列表
        var result = "";
        $.ajax({
            type: "post",
            url: "../../../Handler/DictHandler.ashx",
            dataType: "json",
            data: { type: 5, DictType: $DictType,ParentId:$PId },
            async: false,
            cache: true,
            complete: function () {
            },
            success: function (data) {
                var str = '<option value="-1">请选择</option>';
                $(data.Data).each(function (i, e) {
                    str += '<option value="' + e.DictId + '">' + e.DictName + '</option>';
                });
                result = str;
            }
        });
        return result;
    },
    GetDictById: function ($Id) {
        //根据Id获取信息
        var result = "";
        $.ajax({
            type: "post",
            url: "../../../Handler/DictHandler.ashx",
            dataType: "json",
            data: { type: 4,DictId:$Id },
            async: false,
            cache: true,
            success: function (data) {
                result=data;
            }
        });
        return result;
    },

}